<?php
/**
* @version $Id: controller.php 18 2009-12-07 11:22:56Z truongnhan0311 $
* @author truongnhan0311
* @package	wrd component
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
print_r($this->data); 
?>

<script type="text/javascript">
	//<![CDATA[
	var sectioncountrys = new Array;
	<?php
		foreach ($this->lists['countryToCity'] as $k=>$item) {
			echo "sectioncountrys[".$k."] = new Array( '$item->country_id','".addslashes( $item->id )."','".addslashes( $item->name )."' );\n\t\t";
		}
	?>
	var sectioncitys = new Array;
	<?php
		foreach ($this->lists['cityToDistric'] as $k=>$item) {
			echo "sectioncitys[".$k."] = new Array( '$item->city_id','".addslashes( $item->id )."','".addslashes( $item->name )."' );\n\t\t";
		}
	?>

	function changeCity( listname, source, key, orig_key, orig_val ) {
		var list = eval( 'document.default_registration_form.' + listname );

		// empty the list
		for (i in list.options.length) {
			list.options[i] = null;
		}

		var i = 0;
		var j = 0;

		opt = new Option();
		opt.value = 0;
		opt.text = '<?php echo JText::_('WRD_OPT_SELECT_CITY') ?>';
		opt.selected = true;

		list.options[i++] = opt;

		if(key == 249){
			opt = new Option();
			opt.value = 1;
			opt.text = "Ho Chi Minh";
			list.options[i++] = opt;
		}
		for (x in source) {
			if ((source[x][0] == key)) {
				if(source[x][1] != 1){
					opt = new Option();
					opt.value = source[x][1];
					opt.text = source[x][2];
					
					list.options[i++] = opt;
				}
			}
		}
		
		
		list.length = i;
		if(listname == 'city'){
			changeDistric('distric' ,sectioncitys,j,0,0);
		}else{
			changeDistric('c_distric' ,sectioncitys,j,0,0);
		}
	}

	function changeDistric( listname , source, key, orig_key, orig_val){

		var list = eval( 'document.default_registration_form.' + listname );

		for (i in list.options.length) {
			list.options[i] = null;
		}
		var i = 0;
		//if(i == 0){
			opt = new Option();
			opt.value = 0;
			opt.text = '<?php echo JText::_('WRD_OPT_SELECT_DISTRICT') ?>';
			opt.selected = true;
			list.options[i++] = opt;
		//}
		for (x in source) {
			if (source[x][0] == key) {
				opt = new Option();
				opt.value = source[x][1];
				opt.text = source[x][2];

				if ((orig_key == key && orig_val == opt.value) || i == 0) {
					opt.selected = true;
				}
				list.options[i++] = opt;
			}
		}
		
		list.length = i;
	}
</script>
<script type="text/javascript">
jQuery(function(){
    jQuery('#save_and_continue').click(function(index){
        jQuery('#continue').val('1');  
        return true;               
    }); 

    jQuery('#finish').click(function(index){
        jQuery('#continue').val('0');  
        return true;               
    }); 

	$("#phone").keydown(function(event) {
        // Allow: backspace, delete, tab, escape, and enter
        if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 || 
             // Allow: Ctrl+A
            (event.keyCode == 65 && event.ctrlKey === true) || 
             // Allow: home, end, left, right
            (event.keyCode >= 35 && event.keyCode <= 39)) {
                 // let it happen, don't do anything
                 return;
        	}
        else {
            // Ensure that it is a number and stop the keypress
            if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105))
            {
                event.preventDefault(); 
            }
        }
    }); 

	$('#f_name,#l_name').keyup(function() {
		  var f_name = $('#f_name').val();
		  var l_name = $('#l_name').val();
		  
		  $('#name_on_card').val(l_name + ' ' + f_name);
	});
	
});
</script>
<div class="row">
<h2 class="all_reward_header"><?php echo JText::_('WRD_PROFILE_PROFILE')?></h2>
<div id="profile" class="twelve columns">
	<div style="clear: right ; height:0px;">&nbsp;</div>
	<table id="table1" width="100%" cellpadding="5" cellspacing="0" align="center">
		<tr>
			<td class="a-left title">
				<div><label for="title"><h2><?php echo JText::_('WRD_PROFILE_ACCOUNT_PREFERENCE')?></h2></label></div>
				<div class="contenttt">
                	<div class="left">
                        <strong style="color:#3E3061;"><?php echo $this->data->name_on_card; ?></strong><br>
                        <?php echo JText::_('WRD_PROFILE_ACCOUNT_NUM')?> <strong style="color:#3E3061;"><?php echo substr($this->data->member_id,1); ?></strong>
                        <label for="title">
                        	<?php echo JText::_('WRD_PROFILE_BALANCE')?>
                        	 : <span class='link_color'>
                        	 <?php echo number_format($this->p_o_u->point,0,'.',',') ;?>
                        	 
                        	<?php echo JText::_('WRD_PROFILE_POINTS')?> </span></label>
                    </div>
                    <div class="right">
                        <a href="<?php echo JRoute::_('index.php?option=com_wrd&view=profile&layout=myaccount&Itemid=119') ?>"><?php echo JText::_('WRD_PROFILE_VIEW_THE_SUMMARY_OF_YOUR_POINTS')?></a>
                    </div>
                </div>
			</td>
		</tr>
	</table>
    <table id="table2" cellpadding="0" cellspacing="0">
    	<tr>
        	
    <?php 	
    	if($this->data->user_id != 0)
    	{
    		$step = $this->data->step;
    		if($step > 1):
                $pointstep = WrdHelper::totalPointOfEachStep($step);
            endif;
    		
    		switch ($step){
    			case 1:
    			?>
                <td><div class="radius progress success"><span class="meter" style="width: 20%; float:left;"></span><span class="meterload"><?php echo JText::_('WRD_PROFILE_PLEASE_FILL_ALL_FILEDS_OF_THIS_STEP')?></span></div></td>
    			<?php
    			break;
    			case 2:
    			?>
                <td><div class="radius progress success"><span class="meter" style="width: 40%; float:left;"></span><span class="meterload"><?php echo JText::_('WRD_PROFILE_POINT_REWARDS_IS_COMMING_TO_YOUR_ACCOUNT_BY_THIS_STEP')?></span></div></td>
    			<?php
    				break;
    			case 3:
    			?>
                <td><div class="radius progress success"><span class="meter" style="width: 60%; float:left;"></span><span class="meterload"><?php echo JText::_('WRD_PROFILE_POINTS_REWARDS')?></span></div></td>
    			<?php
    				break;
    			case 4:
    			?>
                <td><div class="radius progress success"><span class="meter" style="width: 80%; float:left;"></span><span class="meterload"><?php echo JText::_('WRD_PROFILE_POINTS_AND_FINISH')?></span></div></td>
    			<?php
    				break;
    			case 5:
    			?>
                <td>
                <div class="radius progress success">
                <span class="meter" id="meter100" style="width: 100%; float:left;">
                	<?php echo JText::_('WRD_PROFILE_CONGRATULATION_100_DONE')?>
                	
                </span>
                </div>
                </td>
    			<?php
    				break;
    		}
    	}
    ?>
    	</tr>
    </table>

<form onsubmit="return checkForm(this);" id="profile-registration" name="default_registration_form" class="form-validate" method="post" action="<?php echo JRoute::_('index.php?option=com_wrd&task=profile.save'); ?>">
	<table width="100%" id="default_registration_form" cellpadding="5" cellspacing="0" class="tblfrm">
		<tr>
			<td colspan="2" height="30">
                <dl class="tabs">
                  <dd class="active"><?php echo JText::_('WRD_PROFILE_BASIC_INFOMATION') ?></dd>
                  <dd><a href="<?php echo JRoute::_('index.php?option=com_wrd&view=profile&layout=default&id=2&Itemid=170') ?>">
                  	<?php echo JText::_('WRD_PROFILE_PERSONAL_INFOMATION') ?></a>
                  </dd>
                  <dd><a href="<?php echo JRoute::_('index.php?option=com_wrd&view=profile&layout=default&id=3&Itemid=170') ?>">
                  	<?php echo JText::_('WRD_PROFILE_BIZ_CONTACT') ?></a>
                  </dd>
                  <dd class="hide-for-small"><a href="<?php echo JRoute::_('index.php?option=com_wrd&view=profile&layout=default&id=4&Itemid=170') ?>">
                  	<?php echo JText::_('WRD_PROFILE_PROFESSIONALISM') ?></a>
                  </dd>
                </dl>
			</td>
		</tr>
        <tr>
        <td>
          <table width="90%" align="center" id="table1_02">
          	<div class="reg_tips" >
          		<div class="reg_tip_content">
          			<p><?php echo JText::_('WRD_PROFILE_THE_FILEDS') ?><b style="color: #FF0000 ; padding: 0px 5px ;">*</b> <?php echo JText::_('WRD_PROFILE_ARE') ?> <b style="color: #FF0000 ; padding: 0px 5px ;"><?php echo JText::_('WRD_PROFILE_REQUIRED') ?></b>.</p>
          			<?php echo JText::_('WRD_PROFILE_STEP1_FILLING_ALL_FIELDS_TIP')?>
          		</div>
          	</div>
            <tr>
                <td class="three">
                    <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_'.$this->configField['prefix']['caption'])); ?></label>
                </td>
                <td>
                	<div class="f-left">	
                        <?php 
                            echo $this->lists['prefix']  ;
                            echo '<b style="color: #FF0000 ; padding: 0px 5px;">*</b>' ;
                        ?>
                        <?php if(!empty($this->configField['prefix']['f_tip'])):?>
                        <span class="l-hint margin-left285 l_prefix"><?php echo $this->configField['prefix']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span>
                        <?php endif;?>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_'.$this->configField['dob']['caption'])); ?></label>
                </td>
                <td>
                	<div class="f-left padding-left30">
                    <?php
                        echo $this->lists['day_birth'] ;
                        echo $this->lists['month_birth'] ;
                        echo $this->lists['year_birth'] ;
                        echo '<b style="color: #FF0000 ; padding: 0px 5px ;">*</b>' ;
						
                    ?>
					<input type="hidden" name="member_id" value="<?php echo $this->user_info->member_id; ?>" />
                    <?php if(!empty($this->configField['dob']['f_tip'])):?>
                        <span class="hint"><?php echo $this->configField['dob']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span>
                    <?php endif ; ?>
                    </div>
                </td>
            </tr>
            <tr>
                <td width="15%">
                    <label for="title">
                        <?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_'.$this->configField['f_name']['caption'])); ?>
                    </label>
                </td>
                <td>
                	<div class="f-left">
                        <input type="text" value="<?php echo $this->data->f_name; ?>" id="f_name" name="f_name" title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_f_name_TIP')); ?>" 
                        class="five has-tip tip-right noradius" />
                        <?php echo '<b style="color: #FF0000 ;  padding: 0px 5px ;">*</b>' ; ?>
                        <?php if(!empty($this->configField['f_name']['f_tip'])):?>
                            <span class="l-hint"><?php echo $this->configField['f_name']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span> 
                        <?php endif ;?>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="key">
                    <label for="title">
                    	<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_'.$this->configField['l_name']['caption'])); ?>
                    </label>
                </td>
                <td>
                    <div class="f-left padding-left30">
                        <input type="text" maxlength="23" size="23" value="<?php echo $this->data->l_name; ?>" id="l_name" name="l_name" 
                        title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_l_name_TIP')); ?>"class="five has-tip tip-right noradius" />
                        <?php
                            echo '<b style="color: #FF0000 ; padding: 0px 5px ;">*</b>' ;
                            if(!empty($this->configField['l_name']['f_tip'])):?>
                            <span class="hint"><?php echo $this->configField['l_name']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span> 
                        <?php endif ; ?>	
                    </div>					
                </td>
            </tr>
            <tr>
                <td>
                    <label for="title">
                    <?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_'.$this->configField['name_on_card']['caption'])); ?></label>
                </td>
                <td>
                    <input readonly="readonly" type="text" maxlength="54" size="54" value="<?php echo $this->data->name_on_card; ?>" id="name_on_card" name="name_on_card" title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_name_on_card_TIP')); ?>" class="five has-tip tip-right noradius" />
                    <?php
                            echo '<b style="color: #FF0000 ;padding: 0px 5px ;">*</b>' ;
                            if(!empty($this->configField['name_on_card']['f_tip'])):?>
                        <span class="hint"><?php echo $this->configField['name_on_card']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span> 
                    <?php endif ; ?>
                </td>
            </tr>
            <tr>
                <td>
                    <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_'.$this->configField['nationality']['caption'])); ?></label>
                </td>
                <td>
                    <?php echo $this->lists['nationality']; ?>
                    <?php
                            echo '<b style="color: #FF0000 ;padding: 0px 5px ;">*</b>' ;
                            if(!empty($this->configField['nationality']['f_tip'])):?>
                        <span class="hint"><?php echo $this->configField['nationality']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span>
                    <?php endif; ?>
                </td>
            </tr>
            <tr>
                <td>
                    <label for="title">
                    <?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_'.$this->configField['p_email']['caption'])); ?></label>
                </td>
                <td>
                    <input type="text" maxlength="54" size="54" value="<?php echo $this->data->p_email == '' ? $this->user->email : $this->data->p_email ; ?>" readonly="readonly" 
                    id="p_email" 
                    name="p_email" 
                    title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_p_email_tip')); ?>" 
                    class="five has-tip tip-right noradius" />
                    <b style="color: #FF0000 ; padding: 0px 5px ;">*</b>
                    <?php
                        if(!empty($this->configField['p_email']['f_tip'])):?>
                        <span class="hint"><?php echo $this->configField['p_email']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span>
                    <?php endif ;?> 
                </td>
            </tr>
            <tr>
                <td>
                    <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_'.$this->configField['alternative_email']['caption'])); ?></label>
                </td>
                <td>
                    <input type="text" maxlength="54" size="54" title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_alternative_email_tip')); ?>" value="<?php echo $this->data->alternative_email ?>" id="alternative_email" name="alternative_email" class="five has-tip tip-right noradius" />
                    <?php
                        if(!empty($this->configField['alternative_email']['f_tip'])):?>
                        <span class="hint"><?php echo $this->configField['alternative_email']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span> 
                    <?php endif ; ?>
                </td>
            </tr>
            <tr>
                <td>
                    <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_'.$this->configField['phone']['caption'])); ?></label>
                </td>
                <td>
                    <div class="f-left padding-left30">
                    	<input readonly="readonly" size="10" type="text" value="+84" id="country_code" 
                    	name="country_code" class="one_countrycode noradius" />
                        <input type="text" maxlength="11" size="23" value="<?php echo $this->data->phone; ?>" id="phone" name="phone" title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_country_code_tip')); ?>" 
                        class="four has-tip tip-right noradius" />
                        <?php
                            echo '<b style="color: #FF0000 ; padding: 0px 5px ;">*</b>' ;
                            if(!empty($this->configField['phone']['f_tip'])):?>
                            <span class="hint"><?php echo $this->configField['phone']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span> 
                        <?php endif ; ?>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_'.$this->configField['address']['caption'])); ?></label>
                </td>
                <td>
                    <input type="text" maxlength="54" size="54" value="<?php echo $this->data->address; ?>" id="address" name="address" 
                    title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_address_tip')); ?>" 
                    class="five has-tip tip-right noradius" />
                    <?php
                        echo '<b style="color: #FF0000 ; padding: 0px 5px ;">*</b>' ;
                        if(!empty($this->configField['address']['f_tip'])):?>
                        <span class="hint"><?php echo $this->configField['address']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span> 
                    <?php endif ; ?>
                </td>
            </tr>
            <tr>
                <td>
                    <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_'.$this->configField['country']['caption'])); ?></label>
                </td>
                <td>
                    <?php 
                        echo $this->lists['country'];
                        echo '<b style="color: #FF0000 ; padding: 0px 5px ;">*</b>' ; 
                    ?>
                    <?php if(!empty($this->configField['country']['f_tip'])):?>
                    <span class="hint"><?php echo $this->configField['country']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span>
                    <?php endif ; ?>
                </td>
            </tr>
            <tr>
                <td>
                    <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_'.$this->configField['city']['caption'])); ?></label>
                </td>
                <td>
                	 <div class='f-left'>
                        <?php 
                            echo $this->lists['city'];
                            echo '<b style="color: #FF0000 ; padding: 0px 5px ;">*</b>' ; 
                        ?>
                        <?php if(!empty($this->configField['city']['f_tip'])):?>
                            <span class="l-hint"><?php echo $this->configField['city']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span>
                        <?php endif ; ?>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="padding-left70">
                    <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_'.$this->configField['distric']['caption'])); ?></label>
                </td>
                <td>
                    <div class='f-left padding-left30'>
                        <?php 
                            echo $this->lists['distric'];
                            echo '<b style="color: #FF0000 ; padding: 0px 5px ;">*</b>' ; 
                        ?>
                        <?php if(!empty($this->configField['distric']['f_tip'])):?>
                        <span class="hint"><?php echo $this->configField['distric']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span>
                        <?php endif ; ?>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_'.$this->configField['pick_up_at']['caption'])); ?></label>
                </td>
                <td>
                    <?php 
                        echo $this->lists['pick_up_oulet'] ; 
                        echo '<b style="color: #FF0000 ; padding: 0px 5px ;">*</b>' ;
                    ?>
                    <?php if(!empty($this->configField['pick_up_at']['f_tip'])):?>
                    <span class="hint"><?php echo $this->configField['pick_up_at']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span>
                    <?php endif ; ?>
                </td>
            </tr>
            <tr>
                <td>
                	<label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_'.$this->configField['lprefer']['caption'])); ?></label>
                </td>
                <td>
                    <?php 
                        echo $this->lists['lang_prefer']; 
                    ?>
                    <?php if(!empty($this->configField['lprefer']['f_tip'])):?>
                    <span class="hint"><?php echo $this->configField['lprefer']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span>
                    <?php endif ; ?>
                </td>
            </tr>
            <tr>
                <td class="key">
                    <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_'.$this->configField['referer']['caption'])); ?></label>
                </td>
                <td>
                    <input type="text" value="<?php echo $this->data->referer ;?>" id="referer" name="referer" title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_referer_tip')); ?>"  
                    class="five has-tip tip-right noradius" size="54" maxlength="54" />
                    <?php 
                    if(!empty($this->configField['referer']['f_tip'])):?>
                        <span class="hint"><?php echo $this->configField['referer']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span>
                    <?php endif ;?>
                </td>
            </tr>
            <tr>
                <td class="key">
                    <label for="title"><?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_'.$this->configField['referer_phone']['caption'])); ?></label>
                </td>
                <td>
                    <input type="text" 
                    value="<?php echo $this->data->referer_phone ;?>" id="referer_phone" name="referer_phone" 
                    title="<?php echo JText::_(WrdHelper::stringURLSafeAliasLang('WRD_PROFILE_STEP1_referer_phone_tip')); ?>" 
                    class="five has-tip tip-right noradius" size="54" maxlength="54" />
                    <?php if(!empty($this->configField['referer_phone']['f_tip'])):?>
                        <span class="hint"><?php echo $this->configField['referer_phone']['f_tip']; ?><span class="hint-pointer">&nbsp;</span></span>
                    <?php endif ;?>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <input type="submit" value="<?php echo JText::_('WRD_PROFILE_SAVE_CONTINUE') ?>" id="save_and_continue" name="save_and_continue" style="cursor: pointer;" class="button_save_and_continue bt" />
                    <input type="submit" value="<?php echo JText::_('WRD_PROFILE_FINISH') ?>" id="finish" name="finish" onclick="" class="button_finish bt" />
                </td>
            </tr>
            </table>
        </td>
      </tr>
	</table>
	<input type="hidden" name="member_id" value="<?php echo $this->user_info->member_id; ?>" />
	<input type="hidden" name="profile" value="<?php echo $this->data->id ?>" />
	<input type="hidden" name="option" value="com_wrd" />
	<input type="hidden" name="task" value="profile.save" />
	<input type="hidden" id="continue" name="continue" value="" />
	<?php echo JHtml::_('form.token');?>
</form>

</div>
</div>

<script type="text/javascript">
                    
	function checkForm(frm){
		
		if(frm.prefix.value == -1){
			alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SELECT_A_TITLE') ?>');
			frm.prefix.focus();
			return false;
		}
		
		<?php if($this->data->dob_already != 1):?>
		    if(frm.day_birth.value== 0 || frm.day_birth.value== ''){
		    	alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SELECT_A_DAY_FOR_YOUR_BIRTHDAY') ?>');
				frm.day_birth.focus();
				return false;
			}
	        if(frm.month_birth.value== 0 || frm.month_birth.value== '')
		    {
		    	alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SELECT_A_MONTH_FOR_YOUR_BIRTHDAY') ?>');
				frm.month_birth.focus();
				return false;
			}
		    if(frm.year_birth.value == "")
		    {
		    	alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SELECT_A_YEAR_FOR_YOUR_BIRTHDAY') ?>');
				frm.year_birth.focus();
				return false;
			}
		    if ((frm.month_birth.value== 2)&&!(((frm.year_birth.value%400) == 0 )||((frm.year_birth.value%4)== 0 &&(frm.year_birth.value%100) != 0 ))){
		        if((frm.day_birth.value>28)){
		        	
		            alert('<?php echo JText::_('WRD_PROFILE_ALERT_DAY_OF_2') ?>'+frm.year_birth.value+' <?php echo JText::_('WRD_PROFILE_ALERT_MUST_BE_SMALLER_THAN_29') ?>');
		    		frm.day_birth.focus();
		    		return false;
		        }    
		    }
		    if((frm.month_birth.value== 2)&&(((frm.year_birth.value%400) == 0 )||((frm.year_birth.value%4)== 0 &&(frm.year_birth.value%100) != 0 ))){
		        if((frm.day_birth.value>29)){
		        	alert('<?php echo JText::_('WRD_PROFILE_ALERT_DAY_OF') ?>'+frm.year_birth.value+'/'+frm.year_birth.value+'<?php echo JText::_('WRD_PROFILE_ALERT_MUST_BE_SMALLER_THAN_30') ?> ');
		        	frm.month_birth.focus();
		    		return false;
		        }    
		    }
		    
		    if((frm.month_birth.value== 4)||(frm.month_birth.value== 6)||(frm.month_birth.value== 9)||(frm.month_birth.value== 11))
		    {
		        if((frm.day_birth.value>30)){
		        	alert('<?php echo JText::_('WRD_PROFILE_ALERT_DAY_OF') ?> '+frm.month_birth.value+'/'+frm.year_birth.value+' <?php echo JText::_('WRD_PROFILE_ALERT_MUST_BE_SMALLER_THAN_31') ?>');
		    		frm.day_birth.focus();
		    		return false;
		        }
		    }
	    <?php endif; ?>
        if(frm.f_name.value == "")
		{
			alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SUPPLY_YOUR_FIRST_NAME') ?>');
			frm.f_name.focus();
			return false;
		}
        if(frm.l_name.value == "")
		{
			alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SUPPLY_YOUR_LAST_NAME') ?>');
			frm.l_name.focus();
			return false;
		}
        if(frm.name_on_card.value == "")
		{
			alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SUPPLY_FULL_NAME_TO_SHOW_ON_YOUR_CARD') ?>');
			frm.name_on_card.focus();
			return false;
		}
        if(frm.nationality.value == 0 || frm.nationality.value == "")
		{
			alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SUPPLY_YOUR_NATIONALTITY') ?>');
			frm.nationality.focus();
			return false;
		}
        if(frm.phone.value == "")
		{
			alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SUPPLY_YOUR_PHONE_NUMBER') ?>');
			frm.phone.focus();
			return false;
		}
        if(isNaN(frm.phone.value)==true || isNaN(frm.phone.value)==1)
		{
			alert('<?php echo JText::_('WRD_PROFILE_ALERT_PHONE_NUMBER_MUST_BE_A_NUMBER') ?>');
			frm.phone.focus();
			return false;
		}
		if(frm.phone.value.length < 9){
			alert('<?php echo JText::_('WRD_PROFILE_ALERT_PHONE_NUMBER_MUST_BE_A_9_12_DIGIT') ?>');
			frm.phone.focus();
			return false;
		}
		
        if(frm.address.value == "")
		{
			alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_TYPE_YOUR_ADDRESS') ?>');
			frm.address.focus();
			return false;
		}
        if(frm.country.value == "" || frm.country.value == 0 )
		{
			alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SUPPY_YOUR_COUNTRY') ?>');
			frm.country.focus();
			return false;
		}
        if(frm.city.value == "" || frm.city.value == 0)
		{
			alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SUPPY_YOUR_CITY') ?>');
			frm.city.focus();
			return false;
		}
        if(frm.distric.value == "" || frm.distric.value == 0)
		{
			alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SUPPY_YOUR_DISTRICT') ?>');
			frm.distric.focus();
			return false;
		}
        if(frm.pick_up_at.value == "" || frm.pick_up_at.value == 0)
		{
			alert('<?php echo JText::_('WRD_PROFILE_ALERT_PLEASE_SELECT_A_OUTLET_TO_PICKUP_THE_CARD') ?>');
			frm.pick_up_at.focus();
			return false;
		}
	    return true;
	}
</script>

